package com.shuke.sk_worm.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shuke.sk_worm.Mapper.HisKpiMapper;
import com.shuke.sk_worm.domain.HisKpi;
import com.shuke.sk_worm.service.HisKpiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HisKpiServiceImpl extends ServiceImpl<HisKpiMapper, HisKpi>
    implements HisKpiService {

    @Autowired
    private HisKpiMapper hisKpiMapper;

    /**
     * 添加数据
     * @param hisKpi
     */
    public int insertData(HisKpi hisKpi){
        return hisKpiMapper.insert(hisKpi);
    }

    public Boolean batchInsertData(List<HisKpi> hisKpis){
        return saveBatch(hisKpis);
    }

    public int deleteData(Long startTime, Long endTime, Integer platform){
        LambdaQueryWrapper<HisKpi> wrapper = new LambdaQueryWrapper<>();
        wrapper.ge(HisKpi::getInsertTimestamp, startTime);
        wrapper.le(HisKpi::getInsertTimestamp, endTime);
        wrapper.eq(HisKpi::getPlatform, platform);
        return hisKpiMapper.delete(wrapper);
    }
}
